<%--
  Created by IntelliJ IDEA.
  User: 我的大名叫陆健伟
  Date: 2016/2/17
  Time: 13:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<div class="pageHeader">
    <form rel="pageForm" onsubmit="return navTabSearch(this);" action="<c:url value='/situation/list'/>" method="post">
        <div class="searchBar">
            <ul>
                <li style="float: left;line-height: 25px; width: 260px">
                    <label style="width:80px;">高速路名称：</label>
                    <input name="highwayName" type="text" value="${query.highwayName}" placeholder="高速路名称"
                           style="width:150px;font-family:'微软雅黑 sans-serif serif';"/>
                </li>
                <li style="float: left;line-height: 25px; width: 140px" >
                    <label style="width:40px;">部门：</label>
                    <select id="txt_situation_area" name="area" class="combox">
                        <option value="">-请选择-</option>
                        <option value="00">辖区</option>
                        <option value="01">全省</option>
                    </select>
                </li>
                <li style="float: left;line-height: 25px; width: 150px">
                    <label style="width:40px;">路况：</label>
                    <select id="txt_situation_highwaySituation" name="highwaySituation" class="combox">
                        <option value="">-请选择-</option>
                        <option value="10">入口关闭</option>
                        <option value="20">通行正常</option>
                        <option value="30">交通拥堵</option>
                    </select>
                </li>
                <li style="float: left; line-height: 25px;">
                    <label style="width:80px;">发布时间：</label>
                    <input name="start" type="text"
                           class="date" datefmt="yyyy-MM-dd HH:mm:ss"
                           value="<fmt:formatDate value="${query.start}" pattern="yyyy-MM-dd HH:mm:ss"/>"
                           placeholder="起始时间"
                           style="width: 100px; font-family: '微软雅黑 sans-serif serif';"/> - <input
                        name="end" type="text" class="date" datefmt="yyyy-MM-dd HH:mm:ss"
                        value="<fmt:formatDate value="${query.end}" pattern="yyyy-MM-dd HH:mm:ss"/>"
                        placeholder="结束时间"
                        style="width: 100px; font-family: '微软雅黑 sans-serif serif';"/>
                </li>
                <li>
                    <div class="buttonActive" style="margin-left: 5px;">
                        <div class="buttonContent">
                            <button type="submit">查找</button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
</div>
<div class="pageContent" style="padding-top: 1px;">
    <div class="panelBar">
        <ul class="toolBar">
            <li><a href="<c:url value='/situation/gotoSituation/0'/>" target="dialog" width="520" height="400" mask="true" resizable="false" maxable="false"  class="add" rel="page_news_add" title="新增高速路况"><span>新增</span></a></li>
            <li><a href="javascript:beforeDelete();" class="delete"><span>删除</span></a></li>
            <li><a href="<c:url value='/situation/gotoSituation/{sel_id}'/>" target="dialog" width="520" height="400" mask="true" resizable="false" maxable="false"  class="add" rel="page_news_edit" title="编辑高速路况"><span>编辑</span></a></li>
            <li class="line">line</li>
        </ul>
    </div>
    <table nowrapTD="false" class="table" width="100%" layoutH="115">
        <thead>
        <tr>
            <th width="40" align="center">高速路名称</th>
            <th width="40" align="center">路况</th>
            <th width="70" align="center">路况明细</th>
            <th width="50" align="center">区域</th>
            <th width="50" align="center">发布单位</th>
            <th width="50" align="center">发布时间</th>
        </tr>
        </thead>
        <tbody>
        <c:if test="${pager.list != null}">
            <c:forEach var="situation" items="${pager.list}" varStatus="vs">
                <tr target="sel_id" rel="${situation.id}">
                    <td>${situation.highwayName}</td>
                    <td>${situation.highwaySituation}</td>
                    <td>${situation.situationDetail}</td>
                    <td>${situation.area}</td>
                    <td>${situation.releaseUnit}</td>
                    <td><fmt:formatDate value="${situation.releaseTime}" pattern="yyyy-MM-dd HH:mm"/></td>
                    <input type="hidden" id="situation${situation.id}" value="${situation.status}">
                </tr>
            </c:forEach>
        </c:if>
        <c:if test="${noData == 1}">
            <tr>
                <td>未查询到数据</td>
            </tr>
        </c:if>
        </tbody>
    </table>
    <div class="panelBar">
        <div class="pages">
            <span>显示&nbsp;</span>
            <select id="cob_ps" class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
                <option value="20">20</option>
                <option value="50">50</option>
                <option value="100">100</option>
                <option value="200">200</option>
            </select>
            <span>条，共${pager.total}条</span>
        </div>
        <div class="pagination" targetType="navTab" totalCount="${pager.total}" numPerPage="${pager.numPerPage}" pageNumShown="10"
             currentPage="${pager.pageNum}"></div>
    </div>
    <form id="pagerForm" method="post" action="<c:url value='/situation/index'/>">
        <input type="hidden" name="pageNum" value="${pager.pageNum}"/>
        <input type="hidden" name="keywords" value="${query.keywords}"/>
        <input type="hidden" name="numPerPage" value="${pager.numPerPage}"/>
        <input type="hidden" name="handler" value="${query.handler}"/>
        <input type="hidden" name="start" value="<fmt:formatDate value="${query.start}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
        <input type="hidden" name="end" value="<fmt:formatDate value="${query.end}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
    </form>
    <input type="hidden" value="${noData}" id="noData">
</div>
<script>
    $(function(){
        $("#txt_situation_area").val("${query.area}");
        $("#txt_situation_highwaySituation").val("${query.highwaySituation}");
    });

    function beforeDelete(){
        //隐藏表单是否有值来判断是否发布
        if(typeof(sel_id) == "undefined"){
            alertMsg.info("请选择待删除高速路况");
            return;
        }
        var id = sel_id.value;

        if($("#situation"+id).val()=="0"){
            alertMsg.confirm("是否删除？",{
                okCall: function(){
                    $.ajax({
                        url: "<c:url value='/situation/deleteSituation/"+id+"'/>",
                        type: "get",
                        success: function (resp, status, xhr) {
                            alertMsg.info(resp.msg);
                            navTab.reloadFlag("page_app_list");
                        }
                    });
                }
            });
        }else{
            alertMsg.info("高速路况已经被删除");
        }
    }
</script>